package com.fulihui.systemcore.dal.convertor;

import com.fulihui.systemcore.dal.dataobj.SysColumn;
import com.fulihui.systemcore.dto.SysColumnDTO;
import org.springframework.util.CollectionUtils;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

public class SysColumnConv {


    public static SysColumn convert2DO(SysColumnDTO mo_) {
        if (mo_ == null) {
            return null;
        }

        SysColumn do_ = new SysColumn();
        do_.setId(mo_.getId());
        do_.setName(mo_.getName());
        do_.setCreateDate(mo_.getCreateDate());
        do_.setImg(mo_.getImg());
        do_.setLevel(mo_.getLevel());
        do_.setParentId(mo_.getParentId());
        do_.setSort(mo_.getSort());
        do_.setStartDate(mo_.getStartDate());
        do_.setStatus(mo_.getStatus());
        do_.setStopDate(mo_.getStopDate());
        do_.setUpdateDate(mo_.getUpdateDate());
        do_.setUrl(mo_.getUrl());
        do_.setKeyName(mo_.getKeyName());

        return do_;
    }

    public static SysColumnDTO convert2DTO(SysColumn do_) {
        if (do_ == null) {
            return null;
        }

        SysColumnDTO mo_ = new SysColumnDTO();
        mo_.setId(do_.getId());
        mo_.setName(do_.getName());
        mo_.setCreateDate(do_.getCreateDate());
        mo_.setImg(do_.getImg());
        mo_.setLevel(do_.getLevel());
        mo_.setParentId(do_.getParentId());
        mo_.setSort(do_.getSort());
        mo_.setStartDate(do_.getStartDate());
        mo_.setStatus(do_.getStatus());
        mo_.setStopDate(do_.getStopDate());
        mo_.setUpdateDate(do_.getUpdateDate());
        mo_.setUrl(do_.getUrl());
        mo_.setKeyName(do_.getKeyName());
        return mo_;
    }

    public static List<SysColumnDTO> convert2List(List<SysColumn> list) {
        if (CollectionUtils.isEmpty(list)) {
            return Collections.emptyList();
        }
        return list.stream().map(SysColumnConv::convert2DTO).collect(Collectors.toList());
    }
}